<div id="kadmin-core">
	<div id="kadmin-object">
		<h3><a href="index.php?route=kse_admin/list/&type=object"><?php echo d_objects ?></a></h3>
		<ul>
		<?php
			/*Objects*/
			$query = "SELECT object_id, object_filesystem_name FROM kse_site_objects WHERE object_slvl>=". $_SESSION["slvl"];
			$result = mysql_query($query);

			while($row = mysql_fetch_assoc($result)){
				echo "<li id=\"li-object-". $row["object_id"] ."\"><a href=\"index.php?route=kse_admin/view/&element=". $row["object_id"] ."&type=object\">". $row["object_filesystem_name"] ."</a></li>";
			}
		?>
		</ul>
	</div>
	<div id="kadmin-template">
		<h3><a href="/index.php?route=kse_admin/list/&type=template"><?php echo d_templates ?></a></h3>
		<ul>
		<?php
			/*Templates*/
			$query = "SELECT template_id, template_filesystem_name FROM kse_site_templates WHERE template_slvl>=". $_SESSION["slvl"];
			$result = mysql_query($query);

			while($row = mysql_fetch_assoc($result)){
				echo "<li id=\"li-template-". $row["template_id"] ."\"><a href=\"index.php?route=kse_admin/view/&element=". $row["template_id"] ."&type=template\">". $row["template_filesystem_name"] ."</a></li>";
			}
		?>
		</ul>
	</div>
	<div id="kadmin-page">
		<h3><a href="index.php?route=kse_admin/list/&type=page&path=root"><?php echo d_pages ?></a></h3>
		<ul>
		<?php
			/*Pages*/
			$query = "SELECT node.page_id, node.page_title, node.page_filesystem_name, node.page_link_text, (COUNT(parent.page_filesystem_name) - (sub_tree.depth + 1)) AS depth
		FROM kse_site_pages AS node,
			kse_site_pages AS parent,
			kse_site_pages AS sub_parent,
			(
				SELECT node.page_filesystem_name, (COUNT(parent.page_filesystem_name) - 1) AS depth
				FROM kse_site_pages AS node,
				kse_site_pages AS parent
				WHERE node.page_lft BETWEEN parent.page_lft AND parent.page_rgt
				AND node.page_filesystem_name = 'root'
				GROUP BY node.page_filesystem_name
				ORDER BY node.page_lft
			)AS sub_tree
		WHERE node.page_lft BETWEEN parent.page_lft AND parent.page_rgt
			AND node.page_lft BETWEEN sub_parent.page_lft AND sub_parent.page_rgt
			AND sub_parent.page_filesystem_name = sub_tree.page_filesystem_name
			AND node.page_slvl>=". $_SESSION["slvl"] ."
		GROUP BY node.page_filesystem_name
		HAVING depth <= 1
		ORDER BY node.page_lft";
			$result = mysql_query($query);

			while($row = mysql_fetch_assoc($result)){
				echo "<li id=\"li-page-". $row["page_id"] ."\"><a href=\"index.php?route=kse_admin/view/&element=". $row["page_id"] ."&type=page\">". $row["page_link_text"] ."</a></li>";
			}
		?>
		</ul>
	</div>
	<div id="kadmin-module">
		<h3><a href="index.php?route=kse_admin/list/&type=module&path=/"><?php echo d_modules ?></a></h3>
		<ul>
		<?php
			/*Modules*/
			$query = "SELECT module_id, module_filesystem_name FROM kse_modules WHERE module_slvl>=". $_SESSION["slvl"];
			$result = mysql_query($query);
			
			if(mysql_num_rows($result) > 0){
				while($row = mysql_fetch_assoc($result)){
					echo "<li id=\"li-page-". $row["module_id"] ."\"><a href=\"index.php?route=kse_admin/view/&element=". $row["module_id"] ."&type=module\">". $row["module_filesystem_name"] ."</a></li>";
				}
			}
		?>
		</ul>
	</div>
</div>